package com.some;

import java.util.Scanner;

public class NetEasy {
    int minTimes = Integer.MAX_VALUE;

    public int killSomeThing(int a, int b, int x, int y) {
        // 思路：采用dfs去遍历每一种情况
        dfs(a, b, x, y, 0);
        return minTimes;
    }

    public void dfs(int a, int b, int x, int y, int times) {
        // 剪枝：两只野怪都被杀死
        if (a <= 0 && b <= 0) {
            minTimes = Math.min(minTimes, times);
            return;
        }
        // 野怪被杀死了一只
        if (a <= 0 || b <= 0) {
            int tmp = Math.max(a, b) / Math.max(x, y);
            if (Math.max(a, b) % Math.max(x, y) == 0) {
                times += tmp;
            } else {
                times += tmp + 1;
            }
            minTimes = Math.min(minTimes, times);
            return;
        }
        // 释放技能：烈焰风暴
        dfs(a - y, b - y, x, y, times + 1);
        // 对野怪a释放火球术
        dfs(a - x, b, x, y, times + 1);
        // 对野怪b释放火球术
        dfs(a, b - x, x, y, times + 1);
    }

    public static void main(String[] args) {
        NetEasy netEasy = new NetEasy();
        Scanner scanner = new Scanner(System.in);
        System.out.println(netEasy.killSomeThing(scanner.nextInt(), scanner.nextInt(), scanner.nextInt(), scanner.nextInt()));

    }
}
